<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>完美电商</title>
    <!-- Bootstrap -->
    <link href="${pageContext.request.contextPath }/static/vendors/bootstrap/dist/css/bootstrap.min.css"
          rel="stylesheet">
    <!-- Font Awesome -->
    <link href="${pageContext.request.contextPath }/static/vendors/font-awesome/css/font-awesome.min.css"
          rel="stylesheet">
    <!-- NProgress -->
    <link href="${pageContext.request.contextPath }/static/vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- iCheck -->
    <link href="${pageContext.request.contextPath }/static/vendors/iCheck/skins/flat/green.css" rel="stylesheet">
    <!-- bootstrap-progressbar -->
    <link href="${pageContext.request.contextPath }/static/vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
          rel="stylesheet">
    <!-- JQVMap -->
    <link href="${pageContext.request.contextPath }/static/vendors/jqvmap/dist/jqvmap.min.css" rel="stylesheet"/>

    <!-- Custom Theme Style -->
    <link href="${pageContext.request.contextPath }/static/build/css/custom.min.css" rel="stylesheet">
</head>

<body class="nav-md">
<div class="container body">
    <div class="main_container">
        <%@include file="/WEB-INF/jsps/menu.jsp" %>
        <!-- top navigation -->
        <%@include file="/WEB-INF/jsps/top.jsp" %>
        <!-- /top navigation -->

        <!-- page content -->
        <div class="right_col" role="main">

            <div class="page-title">
                <div class="title_left">

                    <h3>订单列表
                        <small>订单列表详情</small>
                    </h3>
                </div>
                <div class="title_right">
                    <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
                        <div class="input-group">
                            <%--<form action="${pageContext.request.contextPath}/order/addressListView"--%>
                            <%--method="get">--%>
                            <input id="query" type="text" placeholder="搜索..." class="form-control"
                                   value="${likevalue}"
                                   name="likevalue">
                            <span class="input-group-btn">
                                    <button type="submit" id="likeValueButton" class="btn btn-default">查询</button>
                                        </span>
                            <%--</form>--%>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <%--添加主体内容--%>
                    <div class="x_panel">
                        <div class="x_content">

                            <table class="table table-striped">
                                <thead>
                                <tr>
                                    <th class="column-title">订单编号</th>
                                    <th class="column-title">收货地址</th>
                                    <th class="column-title">商品数量</th>
                                    <th class="column-title">订单状态</th>
                                    <th class="column-title">折扣</th>
                                    <th class="column-title">邮费</th>
                                    <th class="column-title">合计</th>
                                    <th class="column-title">支付方式</th>
                                    <th class="column-title">支付码</th>
                                    <th class="column-title">支付是否成功</th>
                                    <th class="column-title no-link last"><span class="nobr">操作</span>

                                    </th>
                                    <th class="bulk-actions" colspan="7"><a class="antoo"
                                                                            style="color: #fff; font-weight: 500;">Bulk
                                        Actions ( <span
                                                class="action-cnt"> </span> ) <i class="fa fa-chevron-down"></i></a>
                                    </th>

                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach items="${pageInfo.list}" var="orderproduct">

                                    <tr class="even pointer">
                                        <td class=" ">${orderproduct.oid }</td>
                                        <td class=" ">${orderproduct.address.provinceid}${orderproduct.address.cityid}${orderproduct.address.areaid}${orderproduct.address.address}
                                        </td>
                                        <td class=" ">${orderproduct.productnum }</td>
                                        <td class=" ">${orderproduct.ostate }</td>
                                        <td class=" ">${orderproduct.discount }</td>
                                        <td class=" ">${orderproduct.post }</td>
                                        <td class=" ">${orderproduct.total }</td>
                                        <td class=" ">
                                            <c:if test="${orderproduct.paymethod==0 }">
                                                支付宝
                                            </c:if>
                                            <c:if test="${orderproduct.paymethod ==1}">
                                                微信
                                            </c:if>
                                            <c:if test="${orderproduct.paymethod ==2}">
                                                银行卡
                                            </c:if>
                                        </td>
                                        <td class=" ">${orderproduct.paycode }</td>
                                        <td class=" ">
                                            <c:if test="${orderproduct.issuccess ==0}">
                                                已支付
                                            </c:if>
                                            <c:if test="${orderproduct.issuccess ==1}">
                                                未支付
                                            </c:if>
                                        </td>
                                        <td class=" last" colspan="2">
                                            <a href="${pageContext.request.contextPath}/order/getOrderView?oid=${orderproduct.oid}&uid=${orderproduct.uid}"
                                               class="btn btn-info btn-xs"><i
                                                    class="fa fa-pencil"></i>
                                                编辑 </a>
                                            <a href="javascript:void(0);" onclick="delete (${pageInfo.pageNum})"
                                               class="btn btn-danger btn-xs"><i
                                                    class="fa fa-trash-o"></i> 删除 </a>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                            <nav aria-label="Page navigation">
                                <ul class="pagination">
                                    <li <c:if test="${pageInfo.pageNum<=1 }">class="disabled"</c:if>>
                                        <a <c:if
                                                test="${pageInfo.pageNum>1 }"> href="${pageContext.request.contextPath }/order/orderListView?likevalue=${likevalue}&pageNum=1"</c:if>
                                                aria-label="Previous">
                                            <span aria-hidden="true">首页</span>
                                        </a>
                                    </li>
                                    <li <c:if test="${pageInfo.pageNum<=1 }">class="disabled"</c:if>>
                                        <a <c:if
                                                test="${pageInfo.pageNum>1 }"> href="${pageContext.request.contextPath }/order/orderListView?likevalue=${likevalue}&pageNum=${pageInfo.pageNum-1}"</c:if>
                                                aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                    <c:forEach items="${pageInfo.navigatepageNums }" var="nums">
                                        <li <c:if test="${pageInfo.pageNum==nums }">class="active"</c:if>>
                                            <a href="${pageContext.request.contextPath }/order/orderListView?likevalue=${likevalue}&pageNum=${nums }">${nums }</a>
                                        </li>
                                    </c:forEach>
                                    <li <c:if test="${pageInfo.pageNum>=pageInfo.pages }">class="disabled"</c:if>>
                                        <a <c:if
                                                test="${pageInfo.pageNum<pageInfo.pages }"> href="${pageContext.request.contextPath }/order/orderListView?likevalue=${likevalue}&pageNum=${pageInfo.pageNum+1}"</c:if>
                                                aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                    <li <c:if test="${pageInfo.pageNum>=pageInfo.pages }">class="disabled"</c:if>>
                                        <a <c:if
                                                test="${pageInfo.pageNum<pageInfo.pages }"> href="${pageContext.request.contextPath }/order/orderListView?likevalue=${likevalue}&pageNum=${pageInfo.pages}"</c:if>
                                                aria-label="Previous">
                                            <span aria-hidden="true">末页</span>
                                        </a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
            <br/>
        </div>
        <!-- /page content -->

        <!-- footer content -->
        <%@include file="/WEB-INF/jsps/footer.jsp" %>
        <!-- /footer content -->
    </div>
</div>

<!-- jQuery -->
<script src="${pageContext.request.contextPath }/static/vendors/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="${pageContext.request.contextPath }/static/vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="${pageContext.request.contextPath }/static/vendors/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script src="${pageContext.request.contextPath }/static/vendors/nprogress/nprogress.js"></script>
<!-- Chart.js -->
<!-- bootstrap-progressbar -->
<script src="${pageContext.request.contextPath }/static/vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
<!-- iCheck -->
<script src="${pageContext.request.contextPath }/static/vendors/iCheck/icheck.min.js"></script>
<!-- Skycons -->
<script src="${pageContext.request.contextPath }/static/vendors/skycons/skycons.js"></script>
<!-- Custom Theme Scripts -->
<script src="${pageContext.request.contextPath }/static/build/js/custom.min.js"></script>
<script type="text/javascript">
    var pages =${pageInfo.pages};
    var page =${pageInfo.pageNum};
    $(".btn-danger").click(function () {
         var likevalue=$("#query").val();
        console.log("111");
        var oid1 = $(this).parent().parent().find("td").eq(0).text();
        var flag = confirm("确定删除" + oid1 + "这个订单吗？");
        console.log("oid为：" + oid1);
        if (flag) {
            $.ajax({
                url: "${pageContext.request.contextPath}/order/deleteorder",
                data: {"oid": oid1},
                success: function (result) {
                    if (result.code == 0) {
                        window.location.href = "${pageContext.request.contextPath}/order/orderListView?likevalue="+likevalue+"&pageNum=" + page;
                    }
                    else {
                        alert(result.msg);
                    }
                }

            });
        }
    });


    //ajax模糊查询传值
    $(function () {
        $("#likeValueButton").click(function () {
            var likevalue = $("#query").val();
            likevalue = $.trim(likevalue);
            likevalue = likevalue.replace(/[\\\+\&\;\"\%]/g, "");
            window.location.href = "/order/orderListView?likevalue=" + likevalue;
        });
    });
</script>


</body>
</html>
